<!DOCTYPE html>
<html class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title>添加用户</title>
    <#include "../head.ftl">
    <script type="text/javascript" charset="utf8" src="${basePath}/otherjs/Transfer.js"></script>
    <link rel="stylesheet" href="${basePath}/otherjs/style.css">
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form" id="courseInfoForm">
            <div class="layui-form-item">
                <label for="userName" class="layui-form-label">
                    <span class="x-red">*</span>课程名称
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="courseName" name="courseName"
                           value="${courseName?if_exists}" required=""
                           lay-verify="userName"
                           autocomplete="off" class="layui-input" disabled>
                </div>
                <div class="layui-form-mid layui-word-aux">
                    <span class="x-red">*</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label for="userName" class="layui-form-label">
                    <span class="x-red">*</span>课程章节
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="chapterName" name="chapterName"
                           value="${chapterName?if_exists}" required=""
                           lay-verify="chapterName"
                           autocomplete="off" class="layui-input" disabled>
                </div>
            </div>

        </form>
    </div>
</div>
<div class="ty-transfer mt20 ml20" id="ued-transfer-1">
    <div class="fl ty-transfer-list transfer-list-left">
        <div class="ty-transfer-list-head">
            未选择知识列表
        </div>
        <div class="ty-transfer-list-body">
            <ul class="ty-tree-select">
                <#list noSelectKnowledges as k>
                    <li fid="${k.fid?if_exists}">
                        <div class="ty-tree-div">
                            <label class="tyue-checkbox-wrapper">
                            <span class="tyue-checkbox">
                                <input type="checkbox" class="tyue-checkbox-input" id="${k.fid?if_exists}">
                                <span class="tyue-checkbox-circle">
                                </span>
                            </span>
                                <span class="tyue-checkbox-txt" title="${k.title?if_exists}">
                                    ${k.title?if_exists}
                                </span>
                            </label>
                        </div>
                    </li>
                </#list>
            </ul>
        </div>
        <div class="ty-transfer-list-foot">
            <div class="ty-tree-div">
                <div class="tyc-check-blue fl">
                    <input type="checkbox" class="transfer-all-check" id="tyc-check-blue">
                    <span>
                    </span>
                </div>
                <div class="ty-tree-text">
                    全选
                </div>
            </div>
        </div>
    </div>
    <div class="fl ty-transfer-operation">
        <span class="ty-transfer-btn-toright to-switch">
        </span>
        <span class="ty-transfer-btn-toleft to-switch">
        </span>
    </div>
    <div class="fl ty-transfer-list transfer-list-right">
        <div class="ty-transfer-list-head">
            选择知识列表
        </div>
        <div class="ty-transfer-list-body">
            <ul id="fileSelect" class="ty-tree-select">
                <#list selectKnowledges as k>
                    <li fid="${k.fid?if_exists}">
                        <div class="ty-tree-div">
                            <label class="tyue-checkbox-wrapper">
                            <span class="tyue-checkbox">
                                <input type="checkbox" class="tyue-checkbox-input" id="${k.fid?if_exists}">
                                <span class="tyue-checkbox-circle">
                                </span>
                            </span>
                                <span class="tyue-checkbox-txt" title="${k.title?if_exists}">
                                    ${k.title?if_exists}
                                </span>
                            </label>
                        </div>
                    </li>
                </#list>
            </ul>
        </div>
        <div class="ty-transfer-list-foot">
            <div class="ty-tree-div">
                <div class="tyc-check-blue fl">
                    <input type="checkbox" class="transfer-all-check" id="tyc-check-blue">
                    <span>
                    </span>
                </div>
                <div class="ty-tree-text">
                    全选
                </div>
            </div>
        </div>
    </div>
    <div class="clearboth">
    </div>
</div>
<div class="layui-form-item" style="padding-top: 30px">
    <label for="L_repass" class="layui-form-label">
    </label>
    <button class="layui-btn" lay-filter="add" lay-submit="">
        保存
    </button>
</div>
<script>
    layui.use(['form', 'layer'],
            function () {
                $ = layui.jquery;
                var form = layui.form,
                        layer = layui.layer;

                //自定义验证规则
                form.verify({
                    nickName: function (value) {
                        if (value.length < 2) {
                            return '昵称至少得2个字符啊';
                        }
                    },
                    pass: [/(.+){6,12}$/, '密码必须6到12位'],
                    repass: function (value) {
                        if ($('#L_pass').val() != $('#L_repass').val()) {
                            return '两次密码不一致';
                        }
                    }
                });

                form.on('submit(add)',
                        function (data) {
                            var url = "${basePath}/course/chapterCourseMap?id=${id}";
                            $("#fileSelect").find("li").each(function () {      //这里会遍历class为c1下的每一个li元素
                                $(this).each(function () {     //这里会遍历该li元素下的每个p元素
                                    var pId = $(this).attr("fid");      //这里就是该p元素的id
                                    url = url + "&fids=" + pId;
                                });
                            });
                            $.get(url, function (rs) {
                                var obj = eval('(' + rs + ')');
                                if (obj.status == 200) {
                                    layer.alert("保存成功", {icon: 6},
                                            function () {
                                                //关闭当前frame
                                                xadmin.close();
                                                // 可以对父窗口进行刷新
                                                xadmin.father_reload();
                                            });
                                } else {
                                    layer.alert(obj.message);
                                }
                            })
                            return false;
                        });

            });

    $("#ued-transfer-1").transferItem();
</script>
<script>
    var _hmt = _hmt || [];
    (function () {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>
</body>

</html>
